/*
 * Generated via the com.flca generator
 */
package com.logica.hackthon.entity;
import com.flca.frw.dao.IEntity;
import com.logica.hackthon.entity.Game;
import com.logica.hackthon.entity.Player;
import java.io.Serializable;
import javax.persistence.*;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
/**
 * @todo add comment for javadoc
 *
 * @author robin
 * @version $Id: EntityClass.javajet,v 1.3 2007/06/29 21:48:03 robin bakkerus Exp $
 * @generated
 */
@Entity
@Table(name = "GamePlayer")
public class GamePlayer  implements Serializable, Cloneable, IEntity
{
	private static final long serialVersionUID = 123L;
	/** @generated */
	public GamePlayer() {
	}
	
	/** @generated */
	@Basic
@Column(name = "score", length = 255, precision = 0, scale = 0, columnDefinition = "")
	protected Long score = null;
	/** @generated */
	@Basic
@Column(name = "rank", length = 255, precision = 0, scale = 0, columnDefinition = "")
	protected Long rank = null;
	/** @generated */
	@ManyToOne(cascade = {CascadeType.ALL}, fetch = FetchType.EAGER)
@JoinColumn(name = "parent")
	protected Game parent = null;
	/** @generated */
	@ManyToOne(cascade = {CascadeType.ALL}, fetch = FetchType.EAGER)
@JoinColumn(name = "player")
	protected Player player = null;
	/**
	 * @todo add comment for javadoc
	 * Note a returned Set is always NOT null
	 * @generated
	 */
	public Long getScore() {
		return score;
	}
	/** @generated */
	public void setScore(Long score) {
		this.score = score;
	}
	
	/**
	 * @todo add comment for javadoc
	 * Note a returned Set is always NOT null
	 * @generated
	 */
	public Long getRank() {
		return rank;
	}
	/** @generated */
	public void setRank(Long rank) {
		this.rank = rank;
	}
	
	/**
	 * @todo add comment for javadoc
	 * Note a returned Set is always NOT null
	 * @generated
	 */
	public Game getParent() {
		return parent;
	}
	/** @generated */
	public void setParent(Game parent) {
		this.parent = parent;
	}
	
	/**
	 * @todo add comment for javadoc
	 * Note a returned Set is always NOT null
	 * @generated
	 */
	public Player getPlayer() {
		return player;
	}
	/** @generated */
	public void setPlayer(Player player) {
		this.player = player;
	}
	
	/** @generated */
	public String toString() {
		return ToStringBuilder.reflectionToString(this,ToStringStyle.MULTI_LINE_STYLE);
	}	
	/** @generated */
	public int hashCode() {
		final int PRIME = 31;
		int result = 1;
		result = PRIME * result + ((getPk() == null) ? 0 : getPk().hashCode());
		return result;
	}
	/** @generated */
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final GamePlayer other = (GamePlayer) obj;
		if (getPk() != null) {
			return getPk().equals(other.getPk());
		} else {
			return false;
		}
	}		
	/** @generated */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long pk;
		
	public Long getPk() {
		return pk;
	}
	public void setPk(Long aValue) {
		if (aValue != null && aValue.longValue() == 0) {
			pk = null;
		} else {
			pk = aValue;
		}
	}
	
	//we need this because otherwise the AMF will not pass the pk to the AS class
	
	@Transient
	protected long pkValue = 0;
	
	public long getPkValue() {
		if (pk != null) {
			return pk.longValue();
		} else {
			return 0;
		}
	}
	
	public void setPkValue(long aValue) {
		if (aValue != 0) {
			pk = new Long(aValue);
		}
	}
	
}
